<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script th:inline="javascript">
        const basePath = [[${#request.getContextPath()}]];
        function queryById() {
          let param = $('#eid').val();
          $.ajax({
              url:basePath+'/employee/'+param,
              method:'get',
              success:function (rs) {
                  if (rs) {
                      $('#ename').text(rs.name);
                  }else {
                      $('#ename').text("查无此人");
                  }
              }
          })
        }
    </script>
</head>
<body>
<div><input type="text" id="eid" value="0" placeholder="请输入员工id"></div>
<div><button onclick="queryById()" >根据ID进行查询</button></div>
<div>查询出的员工是: <span style="color: red" id="ename">?</span></div>

</body>
</html>